﻿<ClientManagerView:EventResourceDictionary x:Class="FacebookClient.ActivityPostResourcesDictionary"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    xmlns:ClientManager="clr-namespace:ClientManager"
    xmlns:ClientManagerControls="clr-namespace:ClientManager.Controls"
    xmlns:ClientManagerView="clr-namespace:ClientManager.View" 
    xmlns:Facebook="clr-namespace:Contigo;assembly=Contigo" 
    xmlns:FacebookClient="clr-namespace:FacebookClient"
    xmlns:TextSelection="clr-namespace:Microsoft.Wpf.Samples.Documents" >

  <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
  <FacebookClient:DateTimeToStringConverter x:Key="DateTimeConverter" />
  <FacebookClient:MultiValueAggregator x:Key="MultiAggregator" />
  <FacebookClient:ShouldShowCommentBoxConverter x:Key="ShouldShowCommentBoxConverter" />
  <FacebookClient:IsStringNullOrWhitespaceConverter x:Key="IsStringNullOrWhitespaceConverter" />
  <FacebookClient:ContentVisibilityConverter x:Key="ContentVisibilityConverter" />

  <Style x:Key="ProfileNameTextBlockStyle" TargetType="TextBlock">
    <Setter Property="FontFamily" Value="{DynamicResource SansSerifFont}" />
    <Setter Property="FontWeight" Value="SemiBold" />
    <Setter Property="FontSize" Value="{DynamicResource LargeFontSize2}" />
    <Setter Property="Foreground" Value="{DynamicResource ActivityPostUserNameForeground}"/>
  </Style>

  <!-- like, remove like, comment, see more comments, etc. -->
  <Style x:Key="ActivityActionButtonStyle" TargetType="{x:Type ButtonBase}">
    <Setter Property="FontFamily" Value="{DynamicResource SansSerifFont}" />
    <Setter Property="FontSize" Value="{DynamicResource LargeFontSize1}" />
    <Setter Property="Foreground" Value="{DynamicResource ActivityActionButtonForeground}" />
    <Setter Property="Cursor" Value="Hand" />
  </Style>
  
  <ControlTemplate x:Key="LikeButtonTemplate" TargetType="{x:Type Button}">
    <StackPanel Orientation="Horizontal">
      <Image x:Name="Like" Width="13" Height="13" Margin="3,0" Source="pack://application:,,,/Resources/Images/Icons/like_icon.png" />
      <ContentPresenter x:Name="Presenter" VerticalAlignment="Center" TextBlock.FontSize="{TemplateBinding FontSize}" TextBlock.FontWeight="{TemplateBinding FontWeight}" TextBlock.Foreground="{TemplateBinding Foreground}" />
    </StackPanel>
    <ControlTemplate.Triggers>
      <Trigger Property="IsPressed" Value="True">
        <Setter TargetName="Like" Property="Opacity" Value="0.7" />
      </Trigger>
      <Trigger Property="IsEnabled" Value="False">
        <Setter Property="Opacity" Value="0.3" />
      </Trigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>

  <Style x:Key="LikeButtonStyle" BasedOn="{StaticResource ActivityActionButtonStyle}" TargetType="Button">
    <Setter Property="Template" Value="{DynamicResource LikeButtonTemplate}" />
  </Style>
  
  <ControlTemplate x:Key="RemoveLikeButtonTemplate" TargetType="{x:Type Button}">
    <StackPanel Cursor="Hand" Orientation="Horizontal">
      <Image x:Name="Like" Width="13" Height="13" Margin="3,0" RenderTransformOrigin=".5,.5" Source="pack://application:,,,/Resources/Images/Icons/like_icon.png">
        <Image.RenderTransform>
          <RotateTransform Angle="180" />
        </Image.RenderTransform>
      </Image>
      <ContentPresenter x:Name="Presenter" VerticalAlignment="Center" TextBlock.FontSize="{TemplateBinding FontSize}" TextBlock.FontWeight="{TemplateBinding FontWeight}" TextBlock.Foreground="{TemplateBinding Foreground}" />
    </StackPanel>
    <ControlTemplate.Triggers>
      <Trigger Property="IsPressed" Value="True">
        <Setter Property="Opacity" Value="0.7" />
      </Trigger>
      <Trigger Property="IsEnabled" Value="False">
        <Setter Property="Opacity" Value="0.3" />
      </Trigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>
  
  <Style x:Key="RemoveLikeButtonStyle" BasedOn="{StaticResource ActivityActionButtonStyle}" TargetType="{x:Type Button}">
    <Setter Property="Template" Value="{DynamicResource RemoveLikeButtonTemplate}" />
  </Style>

  <ControlTemplate x:Key="CommentButtonTemplate" TargetType="{x:Type ToggleButton}">
    <StackPanel Orientation="Horizontal">
      <Image Width="13" Height="13" Margin="0,0,4,0" Source="pack://application:,,,/Resources/Images/Icons/comment_icon.png" />
      <ContentPresenter x:Name="Presenter" VerticalAlignment="Center" TextBlock.FontSize="{TemplateBinding FontSize}" TextBlock.FontWeight="{TemplateBinding FontWeight}" TextBlock.Foreground="{TemplateBinding Foreground}" />
    </StackPanel>
    <ControlTemplate.Triggers>
      <Trigger Property="IsChecked" Value="True">
        <Setter Property="Opacity" Value="0.7" />
      </Trigger>
      <Trigger Property="IsEnabled" Value="False">
        <Setter Property="Opacity" Value="0.3" />
      </Trigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>

  <Style x:Key="CommentButtonStyle" BasedOn="{StaticResource ActivityActionButtonStyle}" TargetType="{x:Type ButtonBase}">
    <Setter Property="Template" Value="{DynamicResource CommentButtonTemplate}" />
  </Style>
  
  <ControlTemplate x:Key="ShowMoreCommentsButtonTemplate" TargetType="{x:Type ToggleButton}">
    <ContentPresenter x:Name="Presenter" TextBlock.FontSize="{TemplateBinding FontSize}" TextBlock.FontWeight="{TemplateBinding FontWeight}" TextBlock.Foreground="{TemplateBinding Foreground}" />
    <ControlTemplate.Triggers>
      <Trigger Property="IsChecked" Value="True">
        <Setter TargetName="Presenter" Property="Opacity" Value="0.7" />
      </Trigger>
      <Trigger Property="IsEnabled" Value="False">
        <Setter Property="Visibility" Value="Collapsed" />
      </Trigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>
  
  <Style x:Key="ShowMoreCommentsButtonStyle" BasedOn="{StaticResource ActivityActionButtonStyle}" TargetType="{x:Type ButtonBase}">
    <Setter Property="Template" Value="{DynamicResource ShowMoreCommentsButtonTemplate}" />
  </Style>
  
  <Style TargetType="{x:Type Hyperlink}">
    <Setter Property="Foreground" Value="{DynamicResource HyperlinkForegroundBrush}" />
    <Setter Property="TextDecorations" Value="None" />
    <Style.Triggers>
      <Trigger Property="IsMouseOver" Value="True">
        <Setter Property="TextDecorations" Value="Underline" />
      </Trigger>
      <Trigger Property="IsEnabled" Value="True">
        <Setter Property="Cursor" Value="Hand" />
      </Trigger>
    </Style.Triggers>
  </Style>
  
  <ControlTemplate x:Key="RemoveCommentButtonTemplate" TargetType="{x:Type Button}">
    <ContentPresenter x:Name="Presenter" TextBlock.FontSize="{TemplateBinding FontSize}" TextBlock.FontWeight="{TemplateBinding FontWeight}" TextBlock.Foreground="{TemplateBinding Foreground}" />
    <ControlTemplate.Triggers>
      <Trigger Property="IsPressed" Value="True">
        <Setter TargetName="Presenter" Property="Opacity" Value="0.7" />
      </Trigger>
      <Trigger Property="IsEnabled" Value="False">
        <Setter Property="Opacity" Value="0.5" />
      </Trigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>
  
  <Style x:Key="RemoveCommentButtonStyle" BasedOn="{StaticResource CommentButtonStyle}" TargetType="ButtonBase">
    <Setter Property="Template" Value="{DynamicResource RemoveCommentButtonTemplate}" />
  </Style>
  
  <Style x:Key="AttachmentTitleTextBlockStyle" TargetType="TextBlock">
    <Setter Property="FontFamily" Value="{DynamicResource SansSerifFont}" />
    <Setter Property="FontWeight" Value="Medium" />
    <Setter Property="FontSize" Value="{DynamicResource LargeFontSize2}" />
    <Setter Property="TextWrapping" Value="Wrap" />
    <Setter Property="Visibility" Value="Visible" />
    <Setter Property="Foreground" Value="{DynamicResource AttachmentTitleTextBlockForeground}"/>
    <Setter Property="TextSelection:TextSelection.IsEnabled" Value="True" />
  </Style>
  
  <Style x:Key="AttachmentDescriptionTextBlockStyle" TargetType="TextBlock">
    <Setter Property="FontFamily" Value="{DynamicResource SerifFont}" />
    <Setter Property="FontSize" Value="{DynamicResource LargeFontSize1}" />
    <Setter Property="TextWrapping" Value="Wrap" />
    <Setter Property="Margin" Value="0,5,0,0" />
    <Setter Property="Visibility" Value="Visible" />
    <Setter Property="Foreground" Value="{DynamicResource AttachmentDescriptionTextBlockForeground}"/>
    <Setter Property="TextSelection:TextSelection.IsEnabled" Value="True" />
  </Style>
  
  <Style x:Key="AttachmentCaptionTextBlockStyle" TargetType="TextBlock">
    <Setter Property="FontFamily" Value="{DynamicResource SansSerifFont}" />
    <Setter Property="Foreground" Value="#8F8F8F" />
    <Setter Property="FontSize" Value="{DynamicResource MiddleFontSize}" />
    <Setter Property="IsHyphenationEnabled" Value="True" />
    <Setter Property="Margin" Value="0,0,0,5" />
    <Setter Property="Visibility" Value="Visible" />
    <Setter Property="Foreground" Value="{DynamicResource AttachmentCaptionTextBlockForeground}"/>
    <Setter Property="TextSelection:TextSelection.IsEnabled" Value="True" />
    <Style.Triggers>
      <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Text}" Value="">
        <Setter Property="Visibility" Value="Collapsed" />
      </DataTrigger>
    </Style.Triggers>
  </Style>
  
  <Style x:Key="CreatedTextBlockStyle" TargetType="TextBlock">
    <Setter Property="VerticalAlignment" Value="Bottom" />
    <Setter Property="FontFamily" Value="{DynamicResource SansSerifFont}" />
    <Setter Property="FontWeight" Value="Medium" />
    <Setter Property="Foreground" Value="#8F8F8F" />
    <Setter Property="FontSize" Value="{DynamicResource MiddleFontSize}" />
    <Setter Property="IsHyphenationEnabled" Value="True" />
    <Setter Property="TextWrapping" Value="Wrap" />
  </Style>
  
  <Style x:Key="MessageTextBlockStyle" TargetType="TextBlock">
    <Setter Property="FontFamily" Value="{DynamicResource SerifFont}" />
    <Setter Property="FontSize" Value="{DynamicResource LargeFontSize1}" />
    <Setter Property="Foreground" Value="{DynamicResource ActivityPostMessageTextBlockForeground}"/>
    <Setter Property="TextSelection:TextSelection.IsEnabled" Value="True" />
  </Style>

  <DataTemplate x:Key="NewsFeedCommentTemplate" DataType="{x:Type Facebook:ActivityComment}">
    <Grid x:Name="CommentPanel" MinHeight="65" Margin="0,0,0,5">
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="*" />
      </Grid.ColumnDefinitions>
      <Rectangle Height="2" Grid.ColumnSpan="2" Margin="-10,0,-10,-3" VerticalAlignment="Bottom" Fill="{DynamicResource ActivityPostCommentDividerBrush}" SnapsToDevicePixels="True" />
      <FacebookClient:FriendButton
        Margin="5,5,0,0"
        Style="{DynamicResource SquareCommentFriendButtonStyle}"
        Friend="{Binding FromUser}"
        Click="OnNavigateToContentButtonClicked" 
        ClientManagerView:ViewManager.NavigationContent="{Binding FromUser}" />
      <StackPanel Grid.Column="1" HorizontalAlignment="Left" Margin="10,3,0,0">
        <TextBlock MaxWidth="550" FontSize="{DynamicResource MiddleFontSize}" Style="{StaticResource ProfileNameTextBlockStyle}" TextWrapping="Wrap">
          <Hyperlink Click="OnNavigateToContentButtonClicked" ClientManagerView:ViewManager.NavigationContent="{Binding FromUser}">
            <FacebookClient:BindableRun Text="{Binding FromUser.Name}" />
          </Hyperlink>
          <TextBlock Style="{StaticResource CreatedTextBlockStyle}" TextWrapping="Wrap">
            <Span> at </Span>
            <FacebookClient:BindableRun Text="{Binding Time, Converter={StaticResource DateTimeConverter}}"/>
          </TextBlock>
        </TextBlock>
        <TextBlock Margin="0" FontSize="{DynamicResource MiddleFontSize}" Style="{StaticResource MessageTextBlockStyle}" TextWrapping="Wrap">
          <FacebookClient:HyperlinkTextContent Text="{Binding Text}" />
          <Button x:Name="RemoveCommentButton" Command="{Binding Source={x:Static ClientManager:ServiceProvider.ViewManager}, Path=ActionCommands.RemoveCommentCommand}" CommandParameter="{Binding}" Content="Remove" Style="{StaticResource RemoveCommentButtonStyle}" Visibility="Collapsed" />
        </TextBlock>
      </StackPanel>
    </Grid>
    <DataTemplate.Triggers>
      <DataTrigger Binding="{Binding CanRemove}" Value="True">
        <Setter TargetName="RemoveCommentButton" Property="Visibility" Value="Visible" />
      </DataTrigger>
    </DataTemplate.Triggers>
  </DataTemplate>

  <DataTemplate x:Key="NewsFeedCommentNarrowTemplate" DataType="{x:Type Facebook:ActivityComment}">
    <Grid x:Name="CommentPanel" MinHeight="65" Margin="0,0,0,5">
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="*" />
      </Grid.ColumnDefinitions>

      <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="*" />
      </Grid.RowDefinitions>
      
      <Rectangle Height="2" Grid.Row="1" Grid.ColumnSpan="2" Margin="-10,0,-10,-3" VerticalAlignment="Bottom" Fill="{DynamicResource ActivityPostCommentDividerBrush}" SnapsToDevicePixels="True" />
      
      <FacebookClient:FriendButton 
        Margin="5,5,0,0"
        Style="{DynamicResource SquareCommentFriendButtonStyle}"
        Click="OnNavigateToContentButtonClicked" 
        ClientManagerView:ViewManager.NavigationContent="{Binding Path=FromUser}" 
        Friend="{Binding FromUser}" />
      
      <TextBlock Grid.Column="1" HorizontalAlignment="Left" Margin="10,3,0,0" MaxWidth="550" FontSize="{DynamicResource MiddleFontSize}" Style="{StaticResource ProfileNameTextBlockStyle}" TextWrapping="Wrap">
        <Hyperlink Click="OnNavigateToContentButtonClicked" ClientManagerView:ViewManager.NavigationContent="{Binding FromUser}">
          <FacebookClient:BindableRun Text="{Binding FromUser.Name}" />
        </Hyperlink>
        <TextBlock Style="{StaticResource CreatedTextBlockStyle}" TextWrapping="Wrap">
          <Span> at </Span>
          <FacebookClient:BindableRun Text="{Binding Time, Converter={StaticResource DateTimeConverter}}"/>
        </TextBlock>
      </TextBlock>

      <TextBlock Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2" HorizontalAlignment="Left" Margin="2,3,0,0" FontSize="{DynamicResource MiddleFontSize}" Style="{StaticResource MessageTextBlockStyle}" TextWrapping="Wrap">
        <FacebookClient:HyperlinkTextContent Text="{Binding Text}" />
        <Button x:Name="RemoveCommentButton" Command="{Binding Source={x:Static ClientManager:ServiceProvider.ViewManager}, Path=ActionCommands.RemoveCommentCommand}" CommandParameter="{Binding}" Content="Remove" Style="{StaticResource RemoveCommentButtonStyle}" Visibility="Collapsed" />
      </TextBlock>
    </Grid>
    <DataTemplate.Triggers>
      <DataTrigger Binding="{Binding CanRemove}" Value="True">
        <Setter TargetName="RemoveCommentButton" Property="Visibility" Value="Visible" />
      </DataTrigger>
    </DataTemplate.Triggers>
  </DataTemplate>

  <DataTemplate DataType="{x:Type Facebook:ActivityPostAttachment}">
    <Grid>
      <Grid>
        <Grid.Style>
          <Style TargetType="Grid">
            <Setter Property="Visibility" Value="Collapsed" />
            <Style.Triggers>
              <DataTrigger Binding="{Binding Type}" Value="Video">
                <Setter Property="Visibility" Value="Visible" />
              </DataTrigger>
            </Style.Triggers>
          </Style>
        </Grid.Style>
        <StackPanel Orientation="Vertical">
          <TextBlock Style="{StaticResource AttachmentTitleTextBlockStyle}">
            <Hyperlink Click="OnNavigateToContentButtonClicked" ClientManagerView:ViewManager.NavigationContent="{Binding Link}" IsEnabled="True">
              <FacebookClient:BindableRun Text="{Binding Name}"/>
            </Hyperlink>
          </TextBlock>
          <TextBlock Style="{StaticResource AttachmentCaptionTextBlockStyle}" Text="{Binding Caption}" />
          <Button HorizontalAlignment="Left" Click="OnNavigateToContentButtonClicked" ClientManagerView:ViewManager.NavigationContent="{Binding}" IsEnabled="True" Style="{DynamicResource AnimatedItemButton}">
            <Grid MaxHeight="100" Margin="2.5">
              <ClientManagerControls:FacebookImageControl FacebookImage="{Binding VideoPreviewImage}" FacebookImageDimensions="Big">
                <ClientManagerControls:FacebookImageControl.Template>
                  <ControlTemplate TargetType="{x:Type ClientManagerControls:FacebookImageControl}">
                    <Image Margin="2" Source="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ImageSource}" Stretch="Uniform" />
                  </ControlTemplate>
                </ClientManagerControls:FacebookImageControl.Template>
              </ClientManagerControls:FacebookImageControl>
            </Grid>
          </Button>
        </StackPanel>
      </Grid>
      <Grid>
        <Grid.Style>
          <Style TargetType="Grid">
            <Setter Property="Visibility" Value="Collapsed" />
            <Style.Triggers>
              <DataTrigger Binding="{Binding Type}" Value="Photos">
                <Setter Property="Visibility" Value="Visible" />
              </DataTrigger>
            </Style.Triggers>
          </Style>
        </Grid.Style>
        <StackPanel Orientation="Vertical">
          <TextBlock Style="{StaticResource AttachmentTitleTextBlockStyle}" Text="{Binding Name}" />
          <TextBlock Style="{StaticResource AttachmentCaptionTextBlockStyle}" Text="{Binding Caption}" />
          <ItemsControl HorizontalAlignment="Left" ItemsSource="{Binding Photos}">
            <ItemsControl.ItemsPanel>
              <ItemsPanelTemplate>
                <WrapPanel />
              </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
            <ItemsControl.ItemContainerStyle>
              <Style TargetType="{x:Type ContentPresenter}">
                <Style.Triggers>
                  <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsMouseOver}" Value="True">
                    <Setter Property="Panel.ZIndex" Value="4" />
                  </DataTrigger>
                </Style.Triggers>
              </Style>
            </ItemsControl.ItemContainerStyle>
            <ItemsControl.ItemTemplate>
              <DataTemplate>
                <FacebookClient:PhotoButton Photo="{Binding Image}" Click="OnNavigateToContentButtonClicked" ClientManagerView:ViewManager.NavigationContent="{Binding}" Style="{DynamicResource SmallPhotoButtonStyle}"/>
              </DataTemplate>
            </ItemsControl.ItemTemplate>
          </ItemsControl>
        </StackPanel>
      </Grid>
      <Grid>
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="Auto" />
          <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
          <RowDefinition Height="Auto" />
          <RowDefinition Height="Auto" />
          <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        
        <Grid.Style>
          <Style TargetType="Grid">
            <Setter Property="Visibility" Value="Collapsed" />
            <Style.Triggers>
              <DataTrigger Binding="{Binding Type}" Value="Simple">
                <Setter Property="Visibility" Value="Visible" />
              </DataTrigger>
            </Style.Triggers>
          </Style>
        </Grid.Style>

        <TextBlock Grid.Column="1" Grid.Row="0" Style="{StaticResource AttachmentTitleTextBlockStyle}">
          <Hyperlink Click="OnNavigateToContentButtonClicked" ClientManagerView:ViewManager.NavigationContent="{Binding Link}" IsEnabled="True">
            <FacebookClient:BindableRun Text="{Binding Name}"/>
          </Hyperlink>
        </TextBlock>
        <TextBlock Grid.Column="1" Grid.Row="1" Style="{StaticResource AttachmentCaptionTextBlockStyle}" Text="{Binding Caption}" />
        <TextBlock Grid.Column="1" Grid.Row="2" Style="{StaticResource AttachmentDescriptionTextBlockStyle}" TextWrapping="Wrap">
          <FacebookClient:HyperlinkTextContent Text="{Binding Description}" />
        </TextBlock>
      </Grid>
      <Grid>
        <Grid.Style>
          <Style TargetType="Grid">
            <Setter Property="Visibility" Value="Collapsed" />
            <Style.Triggers>
              <DataTrigger Binding="{Binding Type}" Value="Links">
                <Setter Property="Visibility" Value="Visible" />
              </DataTrigger>
            </Style.Triggers>
          </Style>
        </Grid.Style>
        <StackPanel Orientation="Vertical">
          <TextBlock Style="{StaticResource AttachmentTitleTextBlockStyle}">
            <Hyperlink Click="OnNavigateToContentButtonClicked" ClientManagerView:ViewManager.NavigationContent="{Binding Link}" IsEnabled="True">
              <FacebookClient:BindableRun Text="{Binding Name}"/>
            </Hyperlink>
          </TextBlock>
          <TextBlock x:Name="CaptionText" Style="{StaticResource AttachmentCaptionTextBlockStyle}" Text="{Binding Caption}" />
          <ItemsControl x:Name="LinkList" HorizontalAlignment="Left" ItemsSource="{Binding Links}">
            <ItemsControl.Style>
              <Style TargetType="ItemsControl">
                <Setter Property="Visibility" Value="Visible" />
                <Style.Triggers>
                  <DataTrigger Binding="{Binding ElementName=LinkList, Path=Items.Count}" Value="0">
                    <Setter Property="Visibility" Value="Collapsed" />
                  </DataTrigger>
                </Style.Triggers>
              </Style>
            </ItemsControl.Style>
            <ItemsControl.ItemsPanel>
              <ItemsPanelTemplate>
                <WrapPanel />
              </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
            <ItemsControl.ItemTemplate>
              <DataTemplate>
                <FacebookClient:PhotoButton 
                    Click="OnNavigateToContentButtonClicked"
                    ClientManagerView:ViewManager.NavigationContent="{Binding Link}" 
                    Photo="{Binding Image}"
                    Style="{DynamicResource SmallPhotoButtonStyle}"/>
              </DataTemplate>
            </ItemsControl.ItemTemplate>
          </ItemsControl>
          <TextBlock Style="{StaticResource AttachmentDescriptionTextBlockStyle}" TextWrapping="Wrap">
            <FacebookClient:HyperlinkTextContent Text="{Binding Description}" />
          </TextBlock>
        </StackPanel>
      </Grid>
    </Grid>
  </DataTemplate>

  <ControlTemplate x:Key="NewsfeedActivityPostTemplate" TargetType="{x:Type FacebookClient:ActivityPostControl}">
    <Grid x:Name="Root" MinHeight="130" MinWidth="400" Background="Transparent" HorizontalAlignment="Stretch">
      <Rectangle MaxWidth="800" Height="1" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" SnapsToDevicePixels="True" Fill="{DynamicResource NewsFeedItemDividerBrush}"/>

      <Grid MaxWidth="800" HorizontalAlignment="Stretch" Margin="10, 5">
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="Auto" />
          <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <FacebookClient:FriendButton
            Friend="{Binding Actor}"
            Margin="10, 7, 0, 0"
            VerticalAlignment="Top"
            Click="OnNavigateToContentButtonClicked" 
            ClientManagerView:ViewManager.NavigationContent="{Binding Actor}" 
            Style="{DynamicResource LargeFriendButtonStyle}"/>

        <Grid Grid.Column="1" Margin="15,7,0,0" HorizontalAlignment="Stretch">
          <Grid.ColumnDefinitions>
            <ColumnDefinition Width="4*"/>
            <ColumnDefinition Width="*"/>
          </Grid.ColumnDefinitions>
          <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
          </Grid.RowDefinitions>
          <StackPanel Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="0">
            <FacebookClient:ContactNameDisplayControl Foreground="{DynamicResource HyperlinkForegroundBrush}" FacebookContact="{Binding Actor}" TargetFacebookContact="{Binding Target}" />
            <TextBlock Margin="0,5,0,0" Style="{StaticResource MessageTextBlockStyle}" TextWrapping="Wrap" Visibility="{Binding Message, Converter={StaticResource ContentVisibilityConverter}}">
              <FacebookClient:HyperlinkTextContent Text="{Binding Message}" />
            </TextBlock>
            <ContentControl Margin="0,10,0,5" Content="{Binding Attachment}" Visibility="{Binding Attachment, Converter={StaticResource ContentVisibilityConverter}}" />
            <WrapPanel Margin="0,10,5,0" Orientation="Horizontal">
              <ClientManagerControls:FacebookImageControl FacebookImage="{Binding Attachment.Icon}" FacebookImageDimensions="Small">
                <ClientManagerControls:FacebookImageControl.Template>
                  <ControlTemplate TargetType="{x:Type ClientManagerControls:FacebookImageControl}">
                    <Image Height="16" 
                           Width="16" 
                           Margin="0,0,8,0"
                           VerticalAlignment="Center" 
                           Source="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ImageSource}" />
                  </ControlTemplate>
                </ClientManagerControls:FacebookImageControl.Template>
              </ClientManagerControls:FacebookImageControl>

              <TextBlock Style="{StaticResource CreatedTextBlockStyle}" Text="{Binding Created, Converter={StaticResource DateTimeConverter}}" />

              <Button x:Name="LikeButton" Margin="15,0,0,0" VerticalAlignment="Center" Command="{Binding Source={x:Static ClientManager:ServiceProvider.ViewManager}, Path=ActionCommands.AddLikeCommand}" CommandParameter="{Binding}" Content="like" IsEnabled="{Binding CanLike}" ToolTip="Like">
                <Button.Style>
                  <Style BasedOn="{StaticResource LikeButtonStyle}" TargetType="Button">
                    <Setter Property="Visibility" Value="Visible" />
                    <Style.Triggers>
                      <DataTrigger Binding="{Binding HasLiked}" Value="True">
                        <Setter Property="Visibility" Value="Collapsed" />
                      </DataTrigger>
                    </Style.Triggers>
                  </Style>
                </Button.Style>
              </Button>
              <Button x:Name="RemoveLikeButton" Margin="15,0,0,0" VerticalAlignment="Center" Command="{Binding Source={x:Static ClientManager:ServiceProvider.ViewManager}, Path=ActionCommands.RemoveLikeCommand}" CommandParameter="{Binding}" Content="remove like" IsEnabled="{Binding HasLiked}" ToolTip="Remove Like">
                <Button.Style>
                  <Style BasedOn="{StaticResource RemoveLikeButtonStyle}" TargetType="Button">
                    <Setter Property="Visibility" Value="Visible" />
                    <Style.Triggers>
                      <DataTrigger Binding="{Binding HasLiked}" Value="False">
                        <Setter Property="Visibility" Value="Collapsed" />
                      </DataTrigger>
                    </Style.Triggers>
                  </Style>
                </Button.Style>
              </Button>
              <ToggleButton x:Name="CommentButton" Margin="15,0,0,0" VerticalAlignment="Center" Content="comment" IsChecked="{Binding Path=IsAvailable, ElementName=CommentTextBox, Mode=TwoWay}" IsEnabled="{Binding CanComment}" ToolTip="Comment">
                <ToggleButton.Style>
                  <Style BasedOn="{StaticResource CommentButtonStyle}" TargetType="ToggleButton">
                    <Setter Property="Visibility" Value="Collapsed" />
                    <Style.Triggers>
                      <DataTrigger Binding="{Binding Path=CanComment}" Value="True">
                        <Setter Property="Visibility" Value="Visible" />
                      </DataTrigger>
                    </Style.Triggers>
                  </Style>
                </ToggleButton.Style>
              </ToggleButton>
              <ToggleButton x:Name="MoreCommentsButton" Margin="15,0,0,0" VerticalAlignment="Center" Command="{Binding Source={x:Static ClientManager:ServiceProvider.ViewManager}, Path=ActionCommands.GetMoreCommentsCommand}" CommandParameter="{Binding}" Content="see more comments" Style="{StaticResource ShowMoreCommentsButtonStyle}" ToolTip="See All Comments" Visibility="{Binding HasMoreComments, Converter={StaticResource BooleanToVisibilityConverter}}" />
            </WrapPanel>
          </StackPanel>
          <StackPanel Grid.Column="0" Grid.Row="1">
            <Border x:Name="Comments" Margin="0,3,0,0" Background="{DynamicResource NewsFeedCommentBackgroundBrush}" CornerRadius="6,6,0,0" HorizontalAlignment="Stretch">
              <Border.Style>
                <Style TargetType="Border">
                  <Setter Property="Visibility" Value="Visible" />
                  <Style.Triggers>
                    <DataTrigger Binding="{Binding Comments.Count}" Value="0">
                      <Setter Property="Visibility" Value="Collapsed" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding Converter={StaticResource ShouldShowCommentBoxConverter}}" Value="True">
                      <Setter Property="Visibility" Value="Visible" />
                    </DataTrigger>
                  </Style.Triggers>
                </Style>
              </Border.Style>
              <Grid>
                <Grid.RowDefinitions>
                  <RowDefinition Height="Auto"/>
                  <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>

                <Polygon RenderTransformOrigin="0,0" Points="5,0 10,10 0,10 5,0" Fill="{DynamicResource NewsFeedCommentBackgroundBrush}" HorizontalAlignment="Left" Margin="140,-10,0,0" VerticalAlignment="Top" StrokeThickness="0"/>

                <Grid Margin="10" MinHeight="20">
                  <Grid.Style>
                    <Style TargetType="{x:Type Grid}">
                      <Setter Property="Visibility" Value="Visible" />
                      <Style.Triggers>
                        <DataTrigger Binding="{Binding PeopleWhoLikeThis.Count}" Value="0">
                          <Setter Property="Visibility" Value="Collapsed" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding HasLiked}" Value="True">
                          <Setter Property="Visibility" Value="Visible" />
                        </DataTrigger>
                      </Style.Triggers>
                    </Style>
                  </Grid.Style>

                  <TextBlock TextWrapping="Wrap" FontFamily="{DynamicResource SerifFont}" FontSize="{DynamicResource MiddleFontSize}" >
                    <InlineUIContainer>
                      <Image Width="13" Height="13" Margin="3,0" Source="pack://application:,,,/Resources/Images/Icons/like_icon.png" />
                    </InlineUIContainer>
                    <FacebookClient:PeopleWhoLikeThisSpan ActivityPost="{Binding}" Foreground="{DynamicResource PeopleWhoLikeThisForeground}"/>
                  </TextBlock>
                  <Rectangle Height="2" Margin="-10,0,-10,-10" VerticalAlignment="Bottom" Fill="{DynamicResource ActivityPostCommentDividerBrush}" SnapsToDevicePixels="True" />
                </Grid>

                <ItemsControl Grid.Row="1"
                    Margin="10,0,10,0"
                    ItemsSource="{Binding Comments}" 
                    ItemTemplate="{StaticResource NewsFeedCommentTemplate}">
                  <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                      <VirtualizingStackPanel />
                    </ItemsPanelTemplate>
                  </ItemsControl.ItemsPanel>
                </ItemsControl>
              </Grid>
            </Border>
            
            <Border HorizontalAlignment="Left" Margin="0,0,0,3" Background="{DynamicResource NewsFeedCommentBackgroundBrush}" CornerRadius="0,0,6,6">
              <Border.Style>
                <Style TargetType="Border">
                  <Setter Property="Visibility" Value="Collapsed" />
                  <Style.Triggers>
                    <DataTrigger Binding="{Binding Converter={StaticResource ShouldShowCommentBoxConverter}}" Value="True">
                      <Setter Property="Visibility" Value="Visible" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding IsChecked, ElementName=CommentButton}" Value="True">
                      <Setter Property="Visibility" Value="Visible" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding ElementName=Comments, Path=Visibility}" Value="Visible">
                      <Setter Property="Width" Value="{Binding Path=ActualWidth, ElementName=Comments}" />
                    </DataTrigger>
                  </Style.Triggers>
                </Style>
              </Border.Style>
              <StackPanel Margin="7,5,0,7">
                <FacebookClient:CommandTextBox x:Name="CommentTextBox" HorizontalAlignment="Left" Margin="10,5" Panel.ZIndex="1" BannerText="Add to the conversation" CommitCommand="{Binding Source={x:Static ClientManager:ServiceProvider.ViewManager}, Path=ActionCommands.AddCommentCommand}" FontSize="{DynamicResource LargeFontSize1}" SpellCheck.IsEnabled="True" Style="{DynamicResource CommentTextBoxStyle}" TextWrapping="Wrap">
                  <FacebookClient:CommandTextBox.CommitCommandParameter>
                    <MultiBinding Converter="{StaticResource MultiAggregator}">
                      <Binding />
                      <Binding ElementName="CommentTextBox" Path="Text" />
                    </MultiBinding>
                  </FacebookClient:CommandTextBox.CommitCommandParameter>
                </FacebookClient:CommandTextBox>
                <Button Style="{DynamicResource StandardButtonStyle}" IsEnabled="{Binding ElementName=CommentTextBox, Path=Text, Converter={StaticResource IsStringNullOrWhitespaceConverter}, ConverterParameter=Inverse}" Height="22" HorizontalAlignment="Right" Margin="10,4,10,0" Panel.ZIndex="0" Command="{x:Static FacebookClient:CommandTextBox.DoCommitCommand}" CommandTarget="{Binding ElementName=CommentTextBox}" Content="Comment" FontSize="{DynamicResource LargeFontSize1}">
                  <Button.CommandParameter>
                    <MultiBinding Converter="{StaticResource MultiAggregator}">
                      <Binding />
                      <Binding ElementName="CommentTextBox" Path="Text" />
                    </MultiBinding>
                  </Button.CommandParameter>
                </Button>
              </StackPanel>
            </Border>
          </StackPanel>
        </Grid>
      </Grid>
    </Grid>
    <ControlTemplate.Triggers>
      <DataTrigger Binding="{Binding ElementName=CommentButton, Path=IsChecked}" Value="True">
        <Setter TargetName="CommentTextBox" Property="FocusManager.FocusedElement" Value="{Binding ElementName=CommentTextBox}" />
      </DataTrigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>

  <Style x:Key="CommentTextBoxStyle" TargetType="{x:Type FacebookClient:CommandTextBox}">
    <Setter Property="SpellCheck.IsEnabled" Value="True" />
    <Setter Property="KeyboardNavigation.TabNavigation" Value="None" />
    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
    <Setter Property="AllowDrop" Value="true" />
    <Setter Property="FontSize" Value="{DynamicResource LargeFontSize2}" />
    <Setter Property="Foreground" Value="{DynamicResource CommentTextBoxForeground}" />
    <Setter Property="Background" Value="#FFFFFF" />
    <Setter Property="MinHeight" Value="23" />
    <Setter Property="MaxLines" Value="8" />
    <Setter Property="TextWrapping" Value="Wrap" />
    <Setter Property="AcceptsReturn" Value="True" />
    <Setter Property="FontFamily" Value="{DynamicResource SansSerifFont}" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type FacebookClient:CommandTextBox}">
          <Grid x:Name="RootContainer">
            <Grid Opacity=".5">
              <Grid.ColumnDefinitions>
                <ColumnDefinition Width="15" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="15" />
              </Grid.ColumnDefinitions>
              <Grid.RowDefinitions>
                <RowDefinition Height="9" />
                <RowDefinition Height="*" />
                <RowDefinition Height="9" />
              </Grid.RowDefinitions>
              <Border Grid.ColumnSpan="3" Grid.RowSpan="3" Background="#FFFFFF" CornerRadius="6.5" Opacity=".8" />
              <Image Grid.Column="0" Margin="0,0,-0.1,0" Source="../Images/Controls/text_box_top_left.png" Stretch="Fill" />
              <Image Grid.Column="1" Source="../Images/Controls/text_box_top.png" Stretch="Fill" />
              <Image Grid.Column="2" Margin="-0.1,0,0,0" Source="../Images/Controls/text_box_top_right.png" Stretch="Fill" />
              <Image Grid.Column="0" Grid.Row="1" Source="../Images/Controls/text_box_left.png" Stretch="Fill" />
              <Image Grid.Column="2" Grid.Row="1" Source="../Images/Controls/text_box_right.png" Stretch="Fill" />
              <Image Grid.Column="0" Grid.Row="2" Margin="0,0,-0.1,0" Source="../Images/Controls/text_box_bottom_left.png" Stretch="Fill" />
              <Image Grid.Column="1" Grid.Row="2" Source="../Images/Controls/text_box_bottom.png" Stretch="Fill" />
              <Image Grid.Column="2" Grid.Row="2" Margin="-0.1,0,0,0" Source="../Images/Controls/text_box_bottom_right.png" Stretch="Fill" />
            </Grid>
            <TextBlock x:Name="HelpText" HorizontalAlignment="Left" Margin="15,0,0,0" VerticalAlignment="Center" FontFamily="{DynamicResource SansSerifFont}" FontSize="{DynamicResource MiddleFontSize}" FontWeight="Light" Foreground="{DynamicResource CommentTextBoxForeground}" Opacity=".7" Text="{TemplateBinding BannerText}" Visibility="Collapsed" />
            <ScrollViewer x:Name="PART_ContentHost" Margin="7,2,5,0" VerticalAlignment="Center" FontWeight="Medium" />
          </Grid>
          <ControlTemplate.Triggers>
            <MultiTrigger>
              <MultiTrigger.Conditions>
                <Condition Property="IsFocused" Value="False" />
                <Condition Property="Text" Value="" />
              </MultiTrigger.Conditions>
              <Setter TargetName="HelpText" Property="Visibility" Value="Visible" />
            </MultiTrigger>
            <Trigger Property="IsEnabled" Value="false">
              <Trigger.EnterActions>
                <BeginStoryboard>
                  <Storyboard>
                    <DoubleAnimation Duration="0:0:0.1" Storyboard.TargetName="RootContainer" Storyboard.TargetProperty="Opacity" To="0.5" />
                  </Storyboard>
                </BeginStoryboard>
              </Trigger.EnterActions>
              <Trigger.ExitActions>
                <BeginStoryboard>
                  <Storyboard>
                    <DoubleAnimation Duration="0:0:0.5" Storyboard.TargetName="RootContainer" Storyboard.TargetProperty="Opacity" To="1" />
                  </Storyboard>
                </BeginStoryboard>
              </Trigger.ExitActions>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style TargetType="{x:Type FacebookClient:ActivityPostControl}" x:Key="NewsfeedActivityPostStyle">
    <Setter Property="Template" Value="{StaticResource NewsfeedActivityPostTemplate}"/>
  </Style>

  <DataTemplate x:Key="NewsFeedItemTemplate" DataType="{x:Type Facebook:ActivityPost}">
    <FacebookClient:ActivityPostControl ActivityPost="{Binding}" Style="{StaticResource NewsfeedActivityPostStyle}"/>
  </DataTemplate>

</ClientManagerView:EventResourceDictionary>
